pygrub: run first entry in config when invalid default boot option provided
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 20 Mar 2009 15:37:33 +0000 (15:37 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 20 Mar 2009 15:37:33 +0000 (15:37 +0000)
This behaviour matches that of real GRUB.

Signed-off-by: Michal Novotny <minovotn@redhat.com>
tools/pygrub/src/pygrub

index e3a540fa04151f16b8b5e6410d2c3b710d560994..ba70832e62e01716d7049a91882bd5e9fe9571fa 100644 (file)
@@ -530,7 +530,11 @@ def run_grub(file, entry, fs, arg):
         print "No kernel image selected!"
         sys.exit(1)
 
-    img = g.cf.images[sel]
+    try:
+        img = g.cf.images[sel]
+    except:
+        log.debug("PyGrub: Default selection is not valid, using first boot configuration...")
+        img = g.cf.images[0]
 
     grubcfg = { "kernel": None, "ramdisk": None, "args": None }